package cn.tedu.passort.controller;

import cn.tedu.common.web.JsonResult;
import cn.tedu.passort.pojo.param.AddJobApplicantParam;
import cn.tedu.passort.pojo.param.AddRecruiterParam;
import cn.tedu.passort.pojo.param.RegParam;

import cn.tedu.passort.pojo.vo.UserLoginResultVO;
import cn.tedu.passort.service.IUserService;
import com.aliyun.tea.TeaException;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aliyun.tea.*;
import javax.annotation.Resource;
import java.util.Random;

@RestController
@RequestMapping("/users")
@Api(tags = "用户模块")
public class UserController {
    @Autowired
    private IUserService iUserService;

    @PostMapping("sendCode")
    public JsonResult sendCode(@RequestBody RegParam regParam){
        String phone=regParam.getPhone();
        System.out.println(phone);
       iUserService.sendCode(phone);
        return JsonResult.ok();
    }

    @PostMapping("regAndLogin")
    public JsonResult regAndLogin(@RequestBody RegParam regParam){
        UserLoginResultVO userLoginResultVO = iUserService.regAndLogin(regParam);
        return JsonResult.ok(userLoginResultVO);
    }
    @PreAuthorize("hasAuthority('/qiuzhi')")
    @PostMapping("addJobApplicant")
    public JsonResult addJobApplicant(AddJobApplicantParam addJobApplicantParam){
        System.out.println("asdasdasdAsdasdasdasdasdas:"+addJobApplicantParam);
        iUserService.addJobApplicant(addJobApplicantParam);
        return JsonResult.ok();
    }
    @PreAuthorize("hasAuthority('/zhaopin')")
    @PostMapping("addRecruiter")
    public JsonResult addRecruiter(AddRecruiterParam addRecruiterParam){
        iUserService.addRecruiter(addRecruiterParam);
        return JsonResult.ok();
    }


}
